<?php

use yii\helpers\Html;
use kartik\grid\GridView;
use yii\helpers\ArrayHelper;
use yii\helpers\Url;
use frontend\models\ArtForm;
/* @var $this yii\web\View */
/* @var $searchModel common\models\member\MemberSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */

$this->title = Yii::t('app', '文章待审核列表');
$this->params['breadcrumbs'][] = $this->title;
?>
<?php $this->beginBlock('siderbar'); ?>
<?= $this->render('//layouts/cms-menu') ?>
<?php $this->endBlock(); ?>
<div class="member-index">

    <p>

        <button class="btn btn-success" id="start" type="button">审核</button>
  
    </p>

    <?php // echo $this->render('_search', ['model' => $searchModel]); ?>
    <?= GridView::widget([
        'id' => "myform",
        'pjax'=>true,
        'dataProvider' => $dataProvider,
        'filterModel' => $searchModel,
        'containerOptions'=>['style'=>'overflow: auto'], // only set when $responsive = false
        'headerRowOptions'=>['class'=>'kartik-sheet-style'],
        'filterRowOptions'=>['class'=>'filters'],
        'panel'=>[
            'heading'=>'<h3 class="panel-title"><i class="glyphicon glyphicon-globe"></i> 数据列表</h3>',
            'type'=>'default',
            'footer'=>false
        ],
        'toolbar' => [],
        'pager'=>[
            'options'=>['class'=>'hidden']//关闭自带分页
        ],
        'persistResize'=>false,

        'columns' => [
            [
                'class'=>'kartik\grid\CheckboxColumn',
                'headerOptions'=>['class'=>'my-table'],
            ],
            
           

            'title',
            'intro:ntext',
            // 'img',
            //'link',
            //'content:ntext',
            //'seocontent',
            //'seokeyword',
			[
                'attribute' => 'display',
                'format' => 'html',
                'value' => function ($model) {
                    if ($model->display == $model::DIS_SUCCESS) {
                        $class = 'label-success';
                    } elseif ($model->display == $model::DIS_ACTIVE) {
                        $class = 'label-warning';
                    } else {
                        $class = 'label-danger';
                    }

                    return '<span class="label ' . $class . '">' . $model->gradeLabel . '</span>';
                },
                'filterType'=>GridView::FILTER_SELECT2,
                'filter'=>ArtForm::getArrayDis(),
                'filterWidgetOptions'=>[
                    'pluginOptions'=>['allowClear'=>true],
                ],
                'filterInputOptions'=>['placeholder'=>'全部'],
                'format'=>'raw'

            ],
            //'status',
			[
                'attribute' => 'member_id',
                'value' => function($model) {
                   return ArtForm::getMember($model->member_id);
                },   
            ],

            [
                'class' => 'yii\grid\ActionColumn',
                'header' => '操作',
                'template' => '{view}{update}{delete}',
                'headerOptions' => ['width' => '200'],
                'buttons' => [
                    'view' => function ($url, $model, $key) {
                        return  Html::a('&nbsp;&nbsp;<span class="glyphicon glyphicon-eye-open" ><span class="classformat">查看</span></span>', $url, ['title' => '查看'] ) ;
                    },
                    'update' => function ($url, $model, $key) {
                        return Html::a('&nbsp;&nbsp;<span class="glyphicon glyphicon-pencil"><span class="classformat">修改</span></span>', $url, ['title' => '修改'] ) ;
                    },
                    'delete' => function ($url, $model, $key) {
                        return Html::a('&nbsp;&nbsp;<span class="glyphicon glyphicon-trash" ><span class="classformat">删除</span></span>', $url, [
                            'title' => '删除',
                            'data'=>[
                                'confirm'=>'你确定要删除'.$model->title.'吗？',
                                'method'=>'post'
                            ]
                        ] ) ;
                    },
                ],
            ],
        ],
    ]); ?>
    <?= \backend\components\GoLinkPager::widget([
        'pagination' => $dataProvider->pagination,
        'go' => true,
    ]); ?>


</div>
<?php $this->beginBlock('footer_scripts'); ?>
    <script>
        $(document).ready(function(){

            bindcheck("<?php echo Url::to(['art/start']);?>");
            binduncheck("<?php echo Url::to(['art/stop']);?>");
            binddel("<?php echo Url::to(['art/alldelete']);?>");

        });
    </script>
<?php $this->endBlock(); ?>